package com.zelin;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;

/**
 * @Author: Feng.Wang
 * @Company: Zelin.ShenZhen
 * @Description:解析token
 * @Date: Create in 2019/3/28 15:20
 */
public class ParseJwtTest {
    public static void main(String[] args) {
        String token = "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxMTEiLCJpYXQiOjE1NTM3NTgzNTAsInN1YiI6IuWwj-aYjiIsImV4cCI6MTU1Mzc1ODQxMCwicm9sZXMiOiJhZG1pbiJ9.m3p9C3tq5-f-ECm9827vyRoakJnglT3DjGFtxMdRaoQ";
        Claims claims = Jwts.parser().setSigningKey("zelin").parseClaimsJws(token).getBody();
        System.out.println("id:" + claims.getId());
        System.out.println("subject:" + claims.getSubject());
        System.out.println("IssuedAt:" + claims.getIssuedAt());
        System.out.println("roles:" + claims.get("roles"));
    }
}
